﻿/// <reference path="jquery-1.5-vsdoc.js"/>

/*
 **********************************************************************************
 *  Global calls
 **********************************************************************************
 */
(function()
{
    /*
     *  Fix IE background image flicker (from http://www.mister-pixel.com/)
     */
    try
    {
	    document.execCommand('BackgroundImageCache', false, true);
    }
    catch(e) {}
	
	/*
     *  The .bind method from Prototype.js
     */
	if (!Function.prototype.bind) // check if native implementation available
	{
		Function.prototype.bind = function() {
			var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); 
			return function()
			{ 
				return fn.apply(object, args.concat(Array.prototype.slice.call(arguments))); 
			}; 
		};
	}
})();

/**
**********************************************************************************
*   Facebook Configuration
**********************************************************************************
*/
window.fbAsyncInit = function () {
    FB.init({
        appId: Facebook.Config.FbApplicationId,
        status: true, // check login status
        cookie: true, // enable cookies to allow the server to access the session
        xfbml: true // parse XFBML
    });

    FB.getLoginStatus(function (response) {
        if (response.session || Facebook.Config.IsUnauthenticated) {
            $(document).trigger('FB:ready'); // fire custom event when Facebook API is ready for interaction
        }
    });

    $(window).load(function () {
        FB.Canvas.setAutoResize();
    });
};
(function () {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
}());

/**
**********************************************************************************
*   Log
*   usage: log('inside coolFunc',this,arguments);
*   paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
**********************************************************************************
*/
window.log = function() {
    log.history = log.history || []; // store logs to an array for reference
    log.history.push(arguments);
    if (this.console) console.log(Array.prototype.slice.call(arguments));
};

/**
**********************************************************************************
*   catch all document.write() calls
**********************************************************************************
*/ 
(function(doc) {
    var write = doc.write;
    doc.write = function(q) {
        log('document.write(): ',arguments); 
        if (/docwriteregexwhitelist/.test(q)) write.apply(doc,arguments);  
    };
})(document);

/**
**********************************************************************************
*   methods to run on DOM ready
**********************************************************************************
*/
(function($){

})(this.jQuery);